package Theead;

public class RunableDemo implements Runnable {
	private Ticks ticks = new Ticks();

	public void run() {
		int b = 0;
		while (true) {
			synchronized (ticks) {
				if (ticks.getT() <= 0)
					break;
				ticks.sail();
			}
			b++;
		}
		System.out.println    
		(Thread.currentThread().getName()+("卖了"+b+"张票"));
	}

}

class Ticks {
	private int t = 100;

	public int getT() {
		return t;
	}

	public void sail() {
		t--;
	}

}